package com.wu.web;

import com.alibaba.fastjson.JSON;
import com.wu.model.JournalModel;
import com.wu.service.JournalService;
import com.wu.service.impl.JournalServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * 日志的上一条数据
 */
@WebServlet("/SelectJournalPagingUpper")
public class SelectJournalPagingUpperServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id=Integer.parseInt(req.getParameter("id"));
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        JournalService journalService=new JournalServiceImpl();
        JournalModel journalModelTop = journalService.queryJournalTopOne(id);
        String json= JSON.toJSON(journalModelTop).toString();
        resp.getWriter().print(json);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
